package com.student.wym.mapper;

import com.student.wym.po.Teacher;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TeacherMapper {

    @Select("select m.* from ks_manager m  where m.username=#{username} and m.state=0")
    Teacher findOne(String username);

    @Select("select m.* from ks_manager m")
    List<Teacher> findAll();

    @Delete("delete from ks_manager where id=#{id}")
    void delete(int id);

    @Insert("insert into ks_manager(username,password,create_time,state)values(#{username},#{password},#{createTime},#{state})")
    void save(Teacher teacher);

    @Update("update ks_manager set password=#{password} where id=#{id}")
    void update(Teacher teacher);

    @Update("update ks_manager set last_login_time=#{lastLoginTime},last_login_ip=#{lastLoginIp} where username=#{username} and password=#{password}")
    void loginInfo(Teacher teacher);

}
